package jp.eisbahn.mgapi.api.people.lookup;

import java.util.HashMap;
import java.util.Map;

import jp.eisbahn.mgapi.api.Request;
import jp.eisbahn.mgapi.api.Response;
import jp.eisbahn.mgapi.api.people.PeopleResponse;
import jp.eisbahn.mgapi.http.ContentType;
import jp.eisbahn.mgapi.http.HttpMethod;
import jp.eisbahn.mgapi.http.HttpUtils;
import jp.eisbahn.mgapi.util.StringUtils;

public class PeopleLookupRequest implements Request {
    
    public static final String BASE_URI = "/search/people?";
    
    private String[] emails;

    @Override
    public String getUri() {
        String joined = StringUtils.join(emails, ",");
        Map<String, String> parameterMap = new HashMap<String, String>();
        parameterMap.put("q", joined);
        String queryParameterString = HttpUtils.createQueryParameterString(parameterMap);
        return BASE_URI + queryParameterString;
    }

    @Override
    public HttpMethod getHttpMethod() {
        return HttpMethod.GET;
    }

    @Override
    public Class<? extends Response> getResponseClass() {
        return PeopleResponse.class;
    }

    @Override
    public ContentType getContentType() {
        return ContentType.X_WWW_FORM_URLENCODED;
    }

    public void setEmails(String[] emails) {
        this.emails = emails;
    }

    public String[] getEmails() {
        return emails;
    }

}
